package com.shop.shop_end.controller;

import com.shop.shop_end.entity.Cate;
import com.shop.shop_end.service.CateService;
import com.shop.shop_end.utils.PageHelper;
import com.shop.shop_end.utils.result.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author
 * @since 2024-04-23
 */
@RestController
@RequestMapping("/cate")
public class CateController extends BaseController {
    Logger logger = LoggerFactory.getLogger(CateController.class);

    @Resource
    private CateService cateService;

    // 通过主键删除数据
    @RequestMapping("/deleteCate/{id}")
    public Result deleteCate(@PathVariable("id") Long id) {
        return this.cateService.deleteCateById(id);
    }

    // 更新数据
    @RequestMapping("updateCate")
    public Result updateCate(@RequestBody Cate cate) {
        return this.cateService.updateCateById(cate);
    }

    // 添加数据
    @RequestMapping("addCate")
    public Result addCate(@RequestBody Cate cate) {
        return this.cateService.addOneCate(cate);
    }

}
